import { Component } from 'react'
import Parent from './Parent'
import { MyContext } from './context'
const { Provider } = MyContext
export default class Grand extends Component{
  state = { name: 'zheng', age: 18 }
  add = () => {
    this.setState(state => ({ age: state.age + 1 }))
  }
  render(){
    const { name, age } = this.state
    return (
      <div>
        <div>
          <button onClick={this.add}>add</button>
        </div>
        <Provider value={{name, age}}>
          <Parent />
        </Provider>
      </div>
    )
  }
}